package projectmanagement.managementtool.IterationServices;

import projectmanagement.models.Iteration;
import projectmanagement.models.Project;
import projectmanagement.models.Task;

import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * IterationService interface specifies essential methods for
 * iteration-handling.
 *
 * @author Dmitry Shvets
 */
public interface IterationService {
    /**
     * @param project     instance of project for iteration to be added
     * @param startDate   date when iteration starts
     * @param finishDate  date when iteration ends
     * @param description string description
     * @return iteration instance if iteration was created, null if validation failed or project not found
     * @deprecated Tries to create new iteration and add it to project specified
     */
    public Iteration createIteration(Project project, Calendar startDate, Calendar finishDate, String description);

    /**
     * Searches for project by ID and creates iterations for it.
     *
     * @param project  instance of the project where new iterations should be put
     * @param duration duration of each iteration in days
     * @return number of iterations created
     */
    public int scheduleIterations(Project project, int duration);

    /**
     * Returns list of project iterations
     *
     * @param project instance of Project, expected to be not null
     * @return List of iterations
     */
    public Collection<Iteration> getListOfIterations(Project project);

    /**
     * Validates the sanity of timing for iteration
     *
     * @param project    instance of project used to check if iteration begins and finishes within project time limit
     * @param startDate  date when iteration starts
     * @param finishDate date when iteration ends
     * @param duration   duration of iteration in working days
     * @return true when dates provided makes sense i.e. iteration doesn't start before project etc.
     */
    public boolean isTimingValid(Project project, Calendar startDate, Calendar finishDate, int duration);

    /**
     * Validates the sanity of timing for iteration, calculates duration based on start and finish dates
     *
     * @param project    instance of project used to check if iteration begins and finishes within project time limit
     * @param startDate  date when iteration starts
     * @param finishDate date when iteration ends
     * @return true when dates provided makes sense, i.e. iteration doesn't start before project etc.
     */
    public boolean isTimingValid(Project project, Calendar startDate, Calendar finishDate);

    /**
     * Searches and returns iteration by id
     *
     * @param project     instance of Project, expected to be not null
     * @param iterationId unique id of iteration
     * @return iteration if search was successful, null otherwise
     */
    public Iteration getIterationById(Project project, int iterationId);

    /**
     * Returns id of last iteration
     *
     * @return id of last iteration, -1 indicates that there is no iterations
     */
    public int getLastId();
}